import { ref } from "vue";
export default function () {
    const data = {
        //不加ref不能实现双向绑定
        age: ref(20),
        sex: ref('男'),
        department: ref(''),
        skills: ref(['JAVA', 'python', 'vue js']),
        newSkills: ref(''),
        showUserInfo: ref(false),
    }

    const methods = {
        learnNewSkill: () => {
            //在模板中可以直接用，在js中会被看成对象，需要它的value属性
            if (data.newSkills.value) {
                data.skills.value.push(data.newSkills.value)
                data.newSkills.value = ''
            }
        },
        showUserInfo11: () => {
            data.showUserInfo.value = !data.showUserInfo.value
        }
    }

    return{...data,...methods}
}